﻿function previewImg(obj) {
    var img = new Image();
    img.src = obj.src;
    var rate = parseFloat(img.width) / parseFloat(img.height);
    var height = $(window).height() * 0.8;
    var width = height * rate;
    if (img.width < width) {
        width = img.width;
    }
    if (img.height < height) {
        height = img.height;
    }
    var imgHtml = "<div class='layui-row' align='center'><img src='" + obj.src + "' style='display:inline-block;width:" + width + "px;height:" + height + "px;'/></div>";
    //捕获页
    layer.open({
        type: 1,
        title: false, //不显示标题  
        shadeClose: true,
        area: [width, height],
        content: imgHtml, //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响  
        cancel: function () {
            //layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', { time: 5000, icon: 6 });  
        }
    });
}